﻿using System;
using System.Collections.Generic;
using DomainModel;
using Repository.Abstract;

namespace Repository.NHibernate
{
    public class SemesterRepository : Repository<StudySemester>, ISemesterRepository
    {
        public StudySemester GetSemesterByDate(DateTime date)
        {
            return Session.QueryOver<StudySemester>().Where(s => s.BeginDate <= date && s.EndDate >= date).SingleOrDefault();
        }

        public IEnumerable<StudySemester> GetSemestersByStudyYear(StudyYear studyYear)
        {
            return Session.QueryOver<StudySemester>().Where(s => s.StudyYear == studyYear).List();
        }
    }
}